#!groovy

@Library('zw-lib-base@master') _

//sharelibrary
def mytools = new org.devops.tools()
def build = new org.devops.build()

//env
String buildType = "${env.buildType}"
String buildShell = "${env.buildShell}"
String srcUrl = "${env.srcUrl}"
String branchName = "${env.branchName}"


//pipeline
pipeline{
    agent { node { label "master"}}
    
    
    stages{

       stage("获取代码"){
            steps{
                script{
                    println("${branchName}")
                
                    mytools.PrintMes("获取代码","green")
					checkout([$class: 'GitSCM', branches: [[name: '${branchName}']], 
									  doGenerateSubmoduleConfigurations: false, 
									  extensions: [], 
									  submoduleCfg: [], 
									  userRemoteConfigs: [[credentialsId: '20b01136-b5f8-40ac-a438-dcc07b5330b3', url: '${srcUrl}']]])
                }
            }
        }
        stage("执行打包"){
            steps{
                script{
                    sh ''' pwd 
                           echo ${buildType}
                           echo $buildShell{}
                    '''
                    mytools.PrintMes("执行打包","green")
                    build.Build(buildType,buildShell)
                    
                }
            }
        }
        }
post {
    always{
        script{
			mytools.PrintMes("流水线结束后，经常做的事情",'green1')
        }
    }
        
    success{
        script{
			mytools.PrintMes("流水线成功后，要做的事情",'red')
        }
        
    }
    failure{
        script{
            //println("流水线失败后，要做的事情")
			mytools.PrintMes("流水线失败后，要做的事情",'red')
        }
    }
        
    aborted{
        script{
            println("流水线取消后，要做的事情")
        }
        
    }
}
}